<template>
	<u-select v-model="show" mode="mutil-column-auto" :list="list" :default-value="chosenval" @confirm="confirm"></u-select>
</template>

<script>
	export default {
		data() {
			return {
				show: true,
				//chosenval:[0,1, 1],
				chosenval:[1,0, 0],
				list: [
					{
						value: 1,
						label: '中国',
						children: [
							{
								value: 2,
								label: '广东',
								children: [
									{
										value: 3,
										label: '深圳'
									},
									{
										value: 4,
										label: '广州'
									}
								]
							},
							{
								value: 5,
								label: '广西',
								children: [
									{
										value: 6,
										label: '南宁'
									},
									{
										value: 7,
										label: '桂林'
									}
								]
							}
						]
					},
					{
						value: 8,
						label: '美国',
						children: [
							{
								value: 9,
								label: '纽约',
								children: [
									{
										value: 10,
										label: '皇后街区'
									}
								]
							}
						]
					}
				]
			}
		},
		methods: {
			confirm(e) {
				console.log(e,JSON.stringify(e));
				
				 // 获取用户选择的值
				      const selectedLabels = e.map((item) => item.label);
				      this.selectedValue = selectedLabels.join(" - ");
				
				      // 将选择的值转换为 default-value 格式
				      this.defaultValue = e.map((item) => item.value);
				
				      // 打印结果
				      console.log("用户选择的值：", e);
				      console.log("default-value：", this.defaultValue);
				
				
			}
		}
	}
</script>